package passwordmanagement;

public class checkPassword {
    public checkPassword(String password){
        if(checkPasswordStrength(password)<=4){
            System.out.println("密码强度低");
        } else if (checkPasswordStrength(password)>4&&checkPasswordStrength(password)<=6) {
            System.out.println("密码强度一般");
        }else {
            System.out.println("密码强度高");
        }
    }
    public static int checkPasswordStrength(String password) {
        int score = 0;
        if (password.length() < 6) {
            score += 1;
        } else if (password.length() < 10) {
            score += 2;
        } else {
            score += 3;
        }
        if (password.matches(".*\\d+.*")) {
            score += 1;
        }
        if (password.matches(".*[a-z]+.*")) {
            score += 1;
        }
        if (password.matches(".*[A-Z]+.*")) {
            score += 1;
        }
        if (password.matches(".*[!@#$%^&*()_+\\-={}\\[\\]|;:'\",.<>/?]+.*")) {
            score += 1;
        }
        return score;
    }
}
